/***********************************************\
|	"Warehouse's database, Alexander Yushkov"	|
|	- item.h - structured types for storing in	|
|		the database. Also includes some work	|
|		with dates, such as "<","==", and so on	|
\***********************************************/

#ifndef ITEM_H
#define ITEM_H

namespace lmf {

struct Date
{
    int day;
    int mounth;
    int year;
    Date() {}
    Date(int,int,int);
};

bool operator==(const Date&,const Date&);
bool operator!=(const Date&,const Date&);
bool operator>(const Date&,const Date&);
bool operator<(const Date&,const Date&);
bool operator>=(const Date&,const Date&);
bool operator<=(const Date&,const Date&);

struct Group
{
    static const int size=sizeof(Date)+3*sizeof(double);

    Date* date_in;
    double count;
    double price_buy;
    double price_sell;

	Group() { date_in=new Date; }
    Group(Date,double,double,double=0);
    Group(const Group&);
    Group& operator=(const Group&);
    ~Group();
};

struct Record
{
    Date date_sold;
    double count;
    double price;
    double profit;

	Record() {}
    Record(Date d,double c,double p, double pf) : date_sold(d), count(c), price(p), profit(pf) {}
};

void serialize(const Group&,char*);
void serialize(const Record&,char*);
void deserialize(const char*,Group&);
void deserialize(const char*,Record&);

}
#endif
